package com.octopus.xml;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;

public class Dom4jHelper {
	public static Document stringToXMLDocument(String xmlstring) throws DocumentException{
		if(xmlstring == null){
			return null;
		}
		return DocumentHelper.parseText(xmlstring);
	}
	public static String documentToXmlString(Document document){
		if(document == null){
			return null;
		}else{
			return document.asXML();
		}
	}
	public static void main(String args[]) throws DocumentException{
		Document document = stringToXMLDocument("<a><b>asdfasdf</b></a>");
		System.out.println(document);
		System.out.println(document.valueOf("/a/b"));
		System.out.println(documentToXmlString(document));
	}
}
